import java.sql.DriverManager

/**
 *  通过JDBC的方式访问
 */
object SparkSQLThriftServerApp {

  def main(args: Array[String]) {

    Class.forName("org.apache.hive.jdbc.HiveDriver")

    val conn = DriverManager.getConnection("jdbc:hive2://bdptest2:10000","root","zeta@123456")
   // val pstmt = conn.prepareStatement("select * from testuser")

//    val rs = pstmt.executeQuery()
//    while (rs.next()) {
//      println("id:" + rs.getLong("id") +
//        " , name:" + rs.getString("name") +
//        " , age:" + rs.getInt("age"))
//
//    }
    val stmt = conn.createStatement()
   stmt.execute("load data inpath 'hdfs://bdptest1:8020/root/test2/TestUser.txt' overwrite into table TestUser")
  // val sql = ("show tables")
//    val  filepath = "hdfs://bdptest1:8020/root/test2/TestUser.txt";
//    val sql = "load data local inpath '" + filepath + "' into table " + tableName;
//    System.out.println("Running: " + sql)

    stmt.close()

//    rs.close()
//    pstmt.close()
    conn.close()


  }


}
